﻿Imports System.Data.SqlClient
Imports System.Configuration
Public Class frm_xemlichthi
    Sub loadcbolop()
        Dim cmd As New SqlCommand("sp_cboLop", conn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim da As New SqlDataAdapter(cmd)
        Dim tb As New DataTable
        da.Fill(tb)
        cbo_lop.DataSource = tb
        cbo_lop.DisplayMember = "TenLop"
        cbo_lop.ValueMember = "TenLop"
    End Sub
    Private Sub frm_xemlichthi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        loadcbolop()
        cbo_lop.Text = "--------CHỌN LỚP HỌC-------"
    End Sub

    Private Sub cmd_xem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_xem.Click
        If cbo_lop.Text = "--------CHỌN LỚP HỌC-------" Then
            MsgBox("Vui lòng chọn lớp học")
            Exit Sub
        End If
        Dim cmd As New SqlCommand("sp_LichThi_Select", conn)
        cmd.CommandType = CommandType.StoredProcedure

        Dim da As New SqlDataAdapter(cmd)
        Dim tb As New DataTable
        da.Fill(tb)

        dgv_lichthi.DataSource = tb
        tb.DefaultView.RowFilter = String.Format("TenLop = '{0}'", cbo_lop.Text)
    End Sub
End Class